package com.tintintech.sendmail.helper;

import com.tintintech.sendmail.Config;
import com.tintintech.sendmail.util.Json;
import com.tintintech.sendmail.util.MailStore;

import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;

public class DataHelper {

    public static Json JSON = new Json();
    public static MailStore DB = new MailStore(Config.GLOBALS.get("dbPath"), new Long(Config.GLOBALS.get("dbCacheSize")).longValue());

    public static MailStore LOG = new MailStore(Config.GLOBALS.get("dbPath"), new Long(Config.GLOBALS.get("dbCacheSize")).longValue());
    
    static {
        LOG.open(MailStore.LOG_NAME);
    }
    
    /* 邮件发送队列 */
//    public static ConcurrentLinkedQueue<String> MAIL_DATA = new ConcurrentLinkedQueue<String>();
    public static ArrayBlockingQueue<String> MAIL_QUEUE = new ArrayBlockingQueue<String>(new Integer(Config.GLOBALS.get("queueSize")).intValue());//
    /* @todo: compare LinkedBlockingQueue & ArrayBlockingQueue performance */
    public static ArrayBlockingQueue<Map<String, String>> MAILMAP_QUEUE = new ArrayBlockingQueue<Map<String, String>>(new Integer(Config.GLOBALS.get("queueSize")).intValue());//
    
    public static ConcurrentHashMap<String, String> SEND_FAILED_MAP = new ConcurrentHashMap<String, String>(new Integer(Config.GLOBALS.get("queueSize")).intValue());

    public static ConcurrentHashMap<String, String> MAILBOX_MAP = new ConcurrentHashMap<String, String>(new Integer(Config.GLOBALS.get("queueSize")).intValue());
}
